<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    var num1 = 123
    var num2 = 123
    console.log(num1 === num2) // true

    // 1.两个对象比较
    var obj1 = {}
    var obj2 = {}
    console.log(obj1 === obj2) // false

    // 2.引用赋值
    var info = {
      name: "why",
      friend: {
        name: "kobe"
      }
    }
    var friend = info.friend
    friend.name = "james"
    console.log(info.friend.name) // james

    // 3.值传递和引用传递的区别
    function foo(a) {
      a = 200
    }
    var num = 100
    foo(num)
    console.log(num) // 100

    // 4.引用传递,但是在函数中创建了一个新对象,没有对传入的对象进行修改
    function foo(a) {
      a = { name: 'why' }
    }
    var obj = { name: "obj" }
    foo(obj)
    console.log(obj) // {name: 'obj'}

    // 5.引用传递,对传递的对象进行修改
    function foo(a) {
      a.name = "why"
    }
    var obj = { name: "obj" }
    foo(obj)
    console.log(obj)//{name: 'why'}
  </script>
</body>

</html>